package com.zhm.demo.grpc;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import net.devh.boot.grpc.server.service.GrpcService;
import proto.DemoGrpc;
import proto.DemoOuterClass;


/**
 * @author zhanghuaming
 */
@Slf4j
@GrpcService
public class DemoGrpcService extends DemoGrpc.DemoImplBase {


    @PostConstruct
    public void init() {
        log.info("UserGrpcService init");
    }

    /**
     * <pre>
     * 鉴权
     * </pre>
     */
    @Override
    public void login(DemoOuterClass.LoginReq request,
                      io.grpc.stub.StreamObserver<DemoOuterClass.LoginResp> responseObserver) {
        log.info("authorization:{}", request);
        DemoOuterClass.LoginResp res = DemoOuterClass.LoginResp.newBuilder().setAccessToken("asdsadasd").build();
        responseObserver.onNext(res);
        responseObserver.onCompleted();
    }
}
